<div id="publish_{$cid}" class="publishsharewrap">
  <div id="return_publish_{$cid}" style="display:none"></div>
  <form id="form_{$cid}" name="form_{$cid}" class="form-horizontal" action="{DZZSCRIPT}?mod=comment&op=ajax" method="post"  onsubmit="ajaxpost('form_{$cid}','return_publish_{$cid}','return_publish_{$cid}');return false">
    <input type="hidden" name="formhash" value="{FORMHASH}" />
    <input type="hidden" name="replysubmit" value="true" />
    <input type="hidden" name="handlekey" value="publish_{$cid}" />
    <input type="hidden" name="pcid" value="$cid" />
     <input type="hidden" name="id" value="$id" />
      <input type="hidden" name="idtype" value="$idtype" />
      <input type="hidden" name="module" value="$module" />  
    <input id="reply_pid_{$cid}" type="hidden" name="rcid" value="0" />
    <input type="hidden" name="allowattach" value="$_GET['allowattach']" />  
      <input type="hidden" name="allowat" value="$_GET['allowat']" />  
      <input type="hidden" name="allowsmiley" value="$_GET['allowat']" /> 
    <div class="container_psw">
      <div class="notice_cpsw clearfix">
        <div id="reply_who_{$cid}" class="who_cpsw"> <span>{lang reply}</span> <span class="toname_wcpsw"></span> <span>：</span> <a class="closed_wcpsw" title="" hidefocus="true" href="javascript:void(0);" onclick="jQuery(this).parent().hide();jQuery('#reply_pid_$cid').val('0')">{lang close}</a> </div>
      </div>
      <div class="textarea_cpsw">
        <div class="wrap_tcpsw">
          <textarea rows="" id="message_{$cid}" name="message" cols="" onkeyup="check_publish_enable('$cid')"   class="write_wtcpsw _bb_write_wtcpsw " style="overflow: hidden; word-wrap: break-word; resize: vertical;border:none;box-shadow:none;height:25px"></textarea>
        </div>
        <div id="publish_count_{$cid}" class="count_cpsw"> <span id="num_input_{$cid}" class="num_ccpsw">0</span>/<span class="leng_ccpsw">1000</span> </div>
      </div>
    </div>
    <div id="publish_action_{$cid}" class="action_cpsw">
      <ul class="list_acpsw">
      	<!--{if $_GET[allowattach]>0}-->
      	 <li class="ament_lacpsw" style="position: relative; cursor: pointer;">
         <a id="upload_from_{$cid}" onclick="showMenu({'ctrlid':this.id,'evt':'click','layer':2});return false;" href="javascript:;" title="" class="item_lacpsw">{lang typename_attach}/{lang photo}</a> </li>
         <!--{/if}-->
         <!--{if $_GET[allowat]>0}-->
          <li class="at_lacpsw"><a id="at_home_{$cid}" href="javascript:;" title="" class="item_lacpsw">{lang colleague}</a></li>
         <!--{/if}-->
         <!--{if $_GET[allowsmiley]>0}-->
        <li class="emotion_lacpsw"><a href="javascript:;"  class="item_lacpsw" id="message_{$cid}sml" onclick="showMenu({'ctrlid':this.id,'evt':'click','layer':2});return false;">{lang face}</a></li>
         <script type="text/javascript" reload="1"> 
			jcLoader().load({  
				type:'js', 
				ids:'smilies_js', 
				url:'static/js/smilies.js?{VERHASH}'  
			},function(){  
			   smilies_show('message_{$cid}_sml_div','{$_G[setting][smcols]}', 'message_{$cid}');
			});
		   
        </script>
        <!--{/if}-->
      </ul>
      <a hidefocus="true" class="cancel_cpsw" href="javascript:;" onclick="jQuery('#publish_{$cid}').slideUp(500);"> <b><i>{lang cancel}</i></b></a>
      <button id="publish_submit_{$cid}" class="btn btn-sm btn-primary" type="button"  disabled="disabled" title="{lang reply}(Ctrl+Enter)" href="javascript:void(0);"><b>{lang reply}</b></button>
    </div>
     <div id="attachmentViewBox_{$cid}" class="attachmentContainer clearfix"> </div>
  </form>
  <div class="actionUploadAttachment tobody" id="upload_from_{$cid}_menu" style="display:none;">
      <!--{if $_GET[allowattach]>=2 }--><div class="local_auatth" style="position:relative;overflow:hidden"> <a href="javascript:void(0);" hidefocus onclick="jQuery(this).parent().parent().hide();">{lang web_upload} <input id="fileupload_{$cid}" type="file" name="files[]" multiple ></a> </div><!--{/if}-->
        <!--{if $_GET[allowattach]==1 || $_GET[allowattach]>2}-->
      <div class="own_auatth" style=""><a href="javascript:void(0);" hidefocus onclick="uploadfrom_desktop('{$cid}');jQuery(this).parent().parent().hide();">{lang choose_from_my_file}</a></div> 
      <!--{/if}-->
</div>
</div>
<script type="text/javascript" src="dzz/comment/scripts/comment.js?{VERHASH}"></script>
<script type="text/javascript" reload="1">
	jQuery('#upload_from_{$cid}_menu.tobody').removeClass('tobody').appendTo('#append_parent');
    
	
    jQuery('#publish_submit_{$cid}').click(function(){ 
		var val=jQuery('#message_{$cid}').val();
			if(strlen(val)>0 && strlen(val)<1000){
			document.getElementById('form_{$cid}').onsubmit();
		}
	});
	jQuery(document).on('keydown' ,'#form_{$cid}',function(event){
		if(event.ctrlKey && event.keyCode == 13) {
			document.getElementById('form_{$cid}').onsubmit();
		}
	});
	jcLoader().load({  
		type:'js', 
		ids:'caret,atwho', 
		url:'static/atwho/js/jquery.caret.js?{VERHASH},static/atwho/js/jquery.atwho.js?{VERHASH}'  
	},function(){
		jQuery('#message_{$cid}').TextAreaExpander(25,99999);
		<!--{if $_GET[allowat]>0}-->
		jQuery('#at_home_{$cid}').on('mousedown',function(){
			document.getElementById('message_{$cid}').value+='@';
			jQuery('#message_{$cid}').caret('pos',document.getElementById('message_{$cid}').value.length);
			jQuery('#message_{$cid}').focus().atwho('run');
			return false;
		});
		<!--{/if}-->
		<!--{if $_GET[allowattach]>=2}-->
		var attachextensions='{eval echo implode('|',$space[attachextensions]);}';
		if(attachextensions=='') attachextensions="\.*$";
		else attachextensions="(\.|\/)("+(attachextensions)+")$";
		jQuery('#fileupload_{$cid}').fileupload({
			url: DZZSCRIPT+'?mod=comment&op=ajax&do=upload',
			dataType: 'json',
			autoUpload: true,
			maxChunkSize:(parseInt('{$_G[setting][maxChunkSize]}') || 2000000), //2M
			//dropZone:jQuery('#publish_{$cid}'),
			pasteZone:jQuery('#publish_{$cid}'),
			maxFileSize: parseInt('{$space[maxattachsize]}')>0?parseInt('{$space[maxattachsize]}'):null, // 5 MB
			acceptFileTypes:new RegExp(attachextensions,'i'),
			add:function(e,data){
				 data.context = jQuery('<div/>').appendTo('#attachmentViewBox_{$cid}');
				jQuery.each(data.files, function (index, file) {
					if(!file.name) file.name='clipboardData.png';
					
					var html='';
						html+=' <div  class="attachment_previewer">';
						html+='     <div class="attachmentviewbox">';
						html+='         <div class="view_attvb clearfix">';
						html+='           <div class="ico_vattvb "><img alt="'+file.name+'" src="dzz/images/default/upload_failure.png" style="height:50px"></div>';
						html+='  		  <div class="ico_vattvb_right">';
						html+='            	<div class="ico_name">'+file.name+'</div>';
						html+='             <div class="progress  active" style="margin:0;" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="progress-bar progress-bar-success" style="width:0%;"></div></div>';
						html+='          </div>';
						
						html+='      	</div>';
						html+='    </div>';
						html+=' </div>';
					
					jQuery(html).appendTo(data.context);
				});
				
				data.process().done(function () {
					data.submit();
				});
				
			},
			progress: function (e,data){
				 var index = 0;//data.index,
				// file = data.files[index],
				var  node = jQuery(data.context.children()[index]);
				
				  var progress = parseInt(data.loaded / data.total * 100, 10);
					node.find('.progress-bar').css(
						'width',
						progress + '%'
					);
			},
			done: function (e, data) {
				jQuery.each(data.result.files, function (index, file) {
					if(file.error){
						jQuery(data.context.children()[index]).find('.progress').replaceWith('<span class="text-danger">'+file.error+'</span>');
					}else{
						feed_addAttach(file.data,jQuery(data.context.children()[index]),'$cid');
					}
				});
			}
		});
		<!--{/if}-->
		<!--{if $_GET[allowat]>0}-->
		jQuery('#message_{$cid}').atwho({
			at: "@",
			//data: '{DZZSCRIPT}?mod=feed&op=ajax&do=getUserToJson',
			data: '{DZZSCRIPT}?mod=system&op=at&filter=1',
			callbacks:{
						remote_filter: function (query, render_view) {
							var thisVal = query,
							self = jQuery(this);
							if( !self.data('active') && thisVal.length >= 2 ){
								self.data('active', true);                            
								itemsMentions = cachequeryMentions[thisVal]
								if(typeof itemsMentions == "object"){
									render_view(itemsMentions);
								}else
								{                            
									if (self.xhr) {
										self.xhr.abort();
									}
									self.xhr = jQuery.getJSON('{DZZSCRIPT}?mod=system&op=at&filter=1',{
										term: thisVal
									}, function(data) {
										cachequeryMentions[thisVal] = data
										render_view(data);
									});
								}                            
								self.data('active', false);                            
							}                    
						}
			},
			 tpl: "<li data-value='@[${name}:${id}]' title='${title}'><img src='${icon}'>&nbsp;${name}</li>",
			 search_key: "searchkey",
			 start_with_space: false,
			 limit: 5,
			 max_len: 20,
			 display_timeout: 300
		});
		<!--{/if}-->
	});
function succeedhandle_publish_{$cid}(url, message, values) {
	var data= eval('(' + decodeURIComponent(values['data']) + ')');
	feed_reply(data);
	
};
</script> 

